package com.situ.water_system.service.impl;

import com.situ.util.MD5Util;
import com.situ.water_system.mapper.SyDeptMapper;
import com.situ.water_system.pojo.SyDept;
import com.situ.water_system.pojo.SyEmp;
import com.situ.water_system.mapper.SyEmpMapper;
import com.situ.water_system.service.SyEmpService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@Service
public class SyEmpServiceImpl extends ServiceImpl<SyEmpMapper, SyEmp> implements SyEmpService {
    @Autowired
    private SyEmpMapper dao;
    public List<SyEmp> selectList(){
        return  dao.selectList(null);
    }
    @Transactional
    public int del(Serializable id){
        return dao.deleteById(id);
    }
    @Transactional
    public int add(SyEmp syArea){
        syArea.setPwd( MD5Util.md5(syArea.getPwd()));
        return dao.insert(syArea);
    }
    @Transactional
    public int update(SyEmp syArea){
        syArea.setPwd( MD5Util.md5(syArea.getPwd()));
        return dao.updateById(syArea);
    }
    public SyEmp selectByid(Serializable id){
        return  dao.selectById(id);
    }
    public SyEmp queryidmohu(String username,String password){
        Map<String,Object> hashMap = new HashMap();
        hashMap.put("EmpNmae", username);
        hashMap.put("Pwd",password);
        List<SyEmp> syEmps = dao.selectByMap(hashMap);
        if(syEmps.size()>0){
               return syEmps.get(0);
        }
        return null;
    }

}
